<!DOCTYPE html>












  


<html class="theme-next gemini use-motion" lang="en">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">


























<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2">

<link rel="stylesheet" href="/css/main.css?v=7.0.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.0.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32.ico?v=7.0.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16.ico?v=7.0.0">


  <link rel="mask-icon" href="/images/logo.svg?v=7.0.0" color="#222">







<script id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '7.0.0',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":true,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="将 Word 转 pdf 的时候，有很多工具可以使用，其中有一款很不错的工具“Aspose”，可惜是收费软件，但是不打紧，我们就使用一点点小手段crack之，安排。。">
<meta name="keywords" content="编译,Word 转 pdf,Aspose,crack,JByteMod,javassist">
<meta property="og:type" content="article">
<meta property="og:title" content="Word 转 pdf 之 Aspose 工具的“科学使用”">
<meta property="og:url" content="https://blog-test.jetchen.cn/crack-aspose/index.html">
<meta property="og:site_name" content="嘎里三分熟">
<meta property="og:description" content="将 Word 转 pdf 的时候，有很多工具可以使用，其中有一款很不错的工具“Aspose”，可惜是收费软件，但是不打紧，我们就使用一点点小手段crack之，安排。。">
<meta property="og:locale" content="en">
<meta property="og:image" content="http://blogsource.chenkaikai.com/uploads/2019/04/Aspose01.png">
<meta property="og:image" content="http://blogsource.chenkaikai.com/uploads/2019/04/Aspose02.png">
<meta property="og:image" content="http://blogsource.chenkaikai.com/uploads/2019/04/Aspose03.png">
<meta property="og:image" content="http://blogsource.chenkaikai.com/uploads/2019/04/Aspose04.png">
<meta property="og:image" content="http://blogsource.chenkaikai.com/uploads/2019/04/Aspose05.png">
<meta property="og:image" content="http://blogsource.chenkaikai.com/cli_500px.png">
<meta property="og:updated_time" content="2019-04-13T10:01:58.731Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Word 转 pdf 之 Aspose 工具的“科学使用”">
<meta name="twitter:description" content="将 Word 转 pdf 的时候，有很多工具可以使用，其中有一款很不错的工具“Aspose”，可惜是收费软件，但是不打紧，我们就使用一点点小手段crack之，安排。。">
<meta name="twitter:image" content="http://blogsource.chenkaikai.com/uploads/2019/04/Aspose01.png">






  <link rel="canonical" href="https://blog-test.jetchen.cn/crack-aspose/">



<script id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>Word 转 pdf 之 Aspose 工具的“科学使用” | 嘎里三分熟</title>
  












  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="en">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">嘎里三分熟</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="Toggle navigation bar">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">

    
    
    
      
    

    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>Home</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-about">

    
    
    
      
    

    

    <a href="/about-me/" rel="section"><i class="menu-item-icon fa fa-fw fa-user"></i> <br>About</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">

    
    
    
      
    

    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>Archives</a>

  </li>

      
      
    </ul>
  

  

  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
            

          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://blog-test.jetchen.cn/crack-aspose/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Jet Chen">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="嘎里三分熟">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Word 转 pdf 之 Aspose 工具的“科学使用”

              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              

              
                
              

              <time title="Created: 2019-04-13 17:51:19" itemprop="dateCreated datePublished" datetime="2019-04-13T17:51:19+08:00">2019-04-13</time>
            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">In</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/Java基础/" itemprop="url" rel="index"><span itemprop="name">Java基础</span></a></span>

                
                
                  , 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/Java基础/Java工具/" itemprop="url" rel="index"><span itemprop="name">Java工具</span></a></span>

                
                
                  , 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/Java基础/Java工具/技能/" itemprop="url" rel="index"><span itemprop="name">技能</span></a></span>

                
                
              
            </span>
          

          
            
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p><center>将 Word 转 pdf 的时候，有很多工具可以使用，其中有一款很不错的工具“Aspose”，可惜是收费软件，但是不打紧，我们就使用一点点小手段crack之，安排。。</center><br><a id="more"></a></p>
<hr>
<p>搜索微信公众【 <strong>Jet与编程</strong> 】体验更多有趣功能和文章哦。</p>
<p>将 Word 转 pdf 的时候，有很多工具可以使用，其中有一款很不错的工具“Aspose”，可惜是收费软件，但是不打紧，我们就使用一点点小手段crack之，安排。</p>
<hr>
<h2 id="一、背景"><a href="#一、背景" class="headerlink" title="一、背景"></a>一、背景</h2><p>Word 转 pdf 有很多的解决方案，比如先转 html 在转 pdf，但是或多或少都有各种奇(yang)怪(shi)的问题，有一款软件“Aspose”（其实就是一个 jar 包），体验下来很不错，提供了 word 的各种操作 api，但是很可惜是收费的。</p>
<p>身为“贫穷”程序猿的一员，能免费肯定要免费啊，于是就想手动处(po)理(jie)一下这个 jar 包。</p>
<h2 id="二、Crack"><a href="#二、Crack" class="headerlink" title="二、Crack"></a>二、Crack</h2><p>我们先从官网下载 jar 包，地址：<a href="https://downloads.aspose.com/words/java，或者也可在文末下载。" target="_blank" rel="noopener">https://downloads.aspose.com/words/java，或者也可在文末下载。</a></p>
<p>本文下载的是19.1 版本（版本不一致的话，class 中的方法名也可能会有所小差异）。</p>
<p><strong>原理：原理其实很简单，找到 jar 包内 license 校验的地方，将其相关的代码修改掉就 ok。</strong></p>
<h4 id="1、初窥-jar-包内详情"><a href="#1、初窥-jar-包内详情" class="headerlink" title="1、初窥 jar 包内详情"></a>1、初窥 jar 包内详情</h4><p>在此查看 jar 包内详情使用的工具是：JByteMod，文末有下载链接。</p>
<p>追踪源码，我们发现了罪魁祸首，其实就是 License.class 这个文件，然后发现license 的方法内斗指向了一个类zzZLJ，所以接着追踪这个类，然后研究后发现，只需要将 <strong>zzZI0</strong> 和 <strong>zzZI1</strong> 方法的返回值调整为 true 即可，并将 <strong>zzZ</strong> 方法内的校验步骤删掉。见下图：</p>
<p><img src="http://blogsource.chenkaikai.com/uploads/2019/04/Aspose01.png" alt></p>
<p><img src="http://blogsource.chenkaikai.com/uploads/2019/04/Aspose02.png" alt></p>
<p><img src="http://blogsource.chenkaikai.com/uploads/2019/04/Aspose03.png" alt></p>
<h4 id="2、重写验证的方法"><a href="#2、重写验证的方法" class="headerlink" title="2、重写验证的方法"></a>2、重写验证的方法</h4><p>很简单，分两步。</p>
<p>第一步是清除掉 zzZ 方法内的内容，在此使用的是上文提到的 JByteMod 工具，见下图：</p>
<p><img src="http://blogsource.chenkaikai.com/uploads/2019/04/Aspose04.png" alt></p>
<p>第二步是改写 zzZI0 和 zzZI1 方法的返回值，在此使用的是 javassist 工具，需要手动写个测试类去修改内部的方法并生成一个新的 class 文件，见下述代码：<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.javassist<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>javassist<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>3.24.1-GA<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> javassist.ClassPool;</span><br><span class="line"><span class="keyword">import</span> javassist.CtClass;</span><br><span class="line"><span class="keyword">import</span> javassist.CtMethod;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span>  <span class="class"><span class="keyword">class</span>  <span class="title">AsposeWordsCrack191</span>  </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span>  <span class="keyword">static</span>  <span class="keyword">void</span>  <span class="title">main</span><span class="params">(String[]  args)</span>  </span>&#123;</span><br><span class="line">        <span class="keyword">try</span>  &#123;</span><br><span class="line">            AsposeWordsCrack191.changeMethod();</span><br><span class="line">        &#125;  <span class="keyword">catch</span>  (Exception  e)  &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span>  <span class="keyword">static</span>  <span class="keyword">void</span>  <span class="title">changeMethod</span><span class="params">()</span>  <span class="keyword">throws</span>  Exception  </span>&#123;</span><br><span class="line">        ClassPool.getDefault().insertClassPath(<span class="string">"d:\\aspose-words-19.1-jdk16.jar"</span>);</span><br><span class="line">        CtClass c2  =  ClassPool.getDefault().getCtClass(<span class="string">"com.aspose.words.zzZLJ"</span>);</span><br><span class="line"></span><br><span class="line">        CtMethod[]  ms  =  c2.getDeclaredMethods();</span><br><span class="line"></span><br><span class="line">        <span class="keyword">for</span>  (CtMethod  c  :  ms)  &#123;</span><br><span class="line">            CtClass[]  ps  =  c.getParameterTypes();</span><br><span class="line">            <span class="keyword">if</span>  (c.getName().equals(<span class="string">"zzZ"</span>)  &amp;&amp;  ps.length  ==  <span class="number">3</span></span><br><span class="line">                    &amp;&amp;  ps[<span class="number">0</span>].getName().equals(<span class="string">"org.w3c.dom.Node"</span>)</span><br><span class="line">                    &amp;&amp;  ps[<span class="number">1</span>].getName().equals(<span class="string">"org.w3c.dom.Node"</span>)</span><br><span class="line">                    &amp;&amp;  ps[<span class="number">2</span>].getName().equals(<span class="string">"java.lang.String"</span>))  &#123;</span><br><span class="line">                System.out.println(<span class="string">"I got you！zzZ"</span>);</span><br><span class="line">                c.insertBefore(<span class="string">"&#123;return;&#125;"</span>);</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            <span class="keyword">if</span>  (c.getName().equals(<span class="string">"zzZI1"</span>))  &#123;</span><br><span class="line">                System.out.println(<span class="string">"I got you！zzZI1"</span>);</span><br><span class="line">                c.insertBefore(<span class="string">"&#123;return 1;&#125;"</span>);</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            <span class="keyword">if</span>  (c.getName().equals(<span class="string">"zzZI0"</span>))  &#123;</span><br><span class="line">                System.out.println(<span class="string">"I got you！zzZI0"</span>);</span><br><span class="line">                c.insertBefore(<span class="string">"&#123;return 1;&#125;"</span>);</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">//输出到当前目录下</span></span><br><span class="line">        c2.writeFile();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="3、替换字节码文件"><a href="#3、替换字节码文件" class="headerlink" title="3、替换字节码文件"></a>3、替换字节码文件</h4><p>使用上述代码可以生成一个 zzZLJ.class 文件，我们只需要将这个文件替换掉 jar 包内的原始文件即可，在此可以随便找一款压缩工具即可。</p>
<p>但是需要注意，为了防止文件指纹校验，我们需要删除掉 jar 包中的 META_INF 文件夹。</p>
<p>最后，需要生成一个许可文件 com.aspose.words.lic_2999.xml，将其放在 jar 包内即可（不放也可以，但是在checkLicense()方法内读取的时候，需要自己处理下路径），如图：<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">License</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">Data</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">Products</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">Product</span>&gt;</span>Aspose.Words for  Java<span class="tag">&lt;/<span class="name">Product</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">Products</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">EditionType</span>&gt;</span>Enterprise<span class="tag">&lt;/<span class="name">EditionType</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">SubscriptionExpiry</span>&gt;</span>29991231<span class="tag">&lt;/<span class="name">SubscriptionExpiry</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">LicenseExpiry</span>&gt;</span>29991231<span class="tag">&lt;/<span class="name">LicenseExpiry</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">SerialNumber</span>&gt;</span>www.jetchen.cn<span class="tag">&lt;/<span class="name">SerialNumber</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">Data</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">Signature</span>&gt;</span>www.jetchen.cn<span class="tag">&lt;/<span class="name">Signature</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">License</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<p><img src="http://blogsource.chenkaikai.com/uploads/2019/04/Aspose05.png" alt></p>
<h2 id="三、使用"><a href="#三、使用" class="headerlink" title="三、使用"></a>三、使用</h2><p>至于使用也相当简单，但是有一个坑需要注意，经测试发现，在 Windows 平台一切正常，但是在 centos 环境下，转换出来的 pdf 文件中，中文都被替换成了小方框，很显然，是缺少字体的原因。</p>
<p>解决办法有两种，一是在服务器上安装相应的字体库，二是将 Windows 的字体库 copy 一份到服务器上，然后在项目里引用即可。在此推荐第二种，因为第一种有可能会面临重启服务器的情况，并且最主要的是，第一种方案有可能会对服务器上的其他项目产生影响。（附Windows 上 font路径： C:\Windows\Fonts，有好几百兆哦）</p>
<p>官方文档： <a href="https://docs.aspose.com/display/wordsjava/True+Type+Fonts" target="_blank" rel="noopener">https://docs.aspose.com/display/wordsjava/True+Type+Fonts</a></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span>  <span class="class"><span class="keyword">class</span>  <span class="title">CrackSample</span>  </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span>  <span class="keyword">static</span>  <span class="keyword">void</span>  <span class="title">main</span><span class="params">(String[]  args)</span>  <span class="keyword">throws</span>  Exception  </span>&#123;</span><br><span class="line">        String  baseDir  =  <span class="string">"D:\\temp\\"</span>;</span><br><span class="line">        doc2pdf(baseDir  +  <span class="string">"text.docx"</span>,  baseDir  +  <span class="string">"test.pdf"</span>);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">    * <span class="doctag">@Description</span>: 验证License</span></span><br><span class="line"><span class="comment">    * <span class="doctag">@Param</span>: []</span></span><br><span class="line"><span class="comment">    * <span class="doctag">@return</span>: boolean</span></span><br><span class="line"><span class="comment">    * <span class="doctag">@Author</span>: Jet.Chen</span></span><br><span class="line"><span class="comment">    * <span class="doctag">@Date</span>: 2019/4/8 11:52</span></span><br><span class="line"><span class="comment">    */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span>  <span class="keyword">static</span>  <span class="keyword">boolean</span>  <span class="title">checkLicense</span><span class="params">()</span>  <span class="keyword">throws</span>  Exception  </span>&#123;</span><br><span class="line">        <span class="keyword">boolean</span>  result  =  <span class="keyword">false</span>;</span><br><span class="line">        <span class="keyword">try</span>  &#123;</span><br><span class="line">            InputStream is  =  com.aspose.words.Document.class.getResourceAsStream(<span class="string">"/com.aspose.words.lic_2999.xml”);</span></span><br><span class="line"><span class="string">            if (is == null) return false;</span></span><br><span class="line"><span class="string">            License asposeLicense = new License();</span></span><br><span class="line"><span class="string">            asposeLicense.setLicense(is);</span></span><br><span class="line"><span class="string">            System.out.println("</span>Aspose isLicensed:  <span class="string">" + asposeLicense.isLicensed());</span></span><br><span class="line"><span class="string">            result = true;</span></span><br><span class="line"><span class="string">            is.close();</span></span><br><span class="line"><span class="string">        &#125; catch (Exception e) &#123;</span></span><br><span class="line"><span class="string">            e.printStackTrace();</span></span><br><span class="line"><span class="string">            throw e;</span></span><br><span class="line"><span class="string">        &#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">        return result;</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    public static void doc2pdf(String inPath, String outPath) throws Exception &#123;</span></span><br><span class="line"><span class="string">        // 验证License 否则转出的pdf文档有水印</span></span><br><span class="line"><span class="string">        if (!checkLicense()) &#123;</span></span><br><span class="line"><span class="string">            throw new Exception("</span>com.aspose.words lic ERROR!<span class="string">");</span></span><br><span class="line"><span class="string">        &#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">        try &#123;</span></span><br><span class="line"><span class="string">            File file = new File(outPath);</span></span><br><span class="line"><span class="string">            FileOutputStream os = new FileOutputStream(file);</span></span><br><span class="line"><span class="string">            if (!System.getProperty("</span>os.name<span class="string">").toLowerCase().startsWith("</span>windows<span class="string">")) &#123;</span></span><br><span class="line"><span class="string">                // linux 需要配置字体库</span></span><br><span class="line"><span class="string">                FontSettings.getDefaultInstance().setFontsFolder("</span>/data/crm/fonts<span class="string">",  false);</span></span><br><span class="line"><span class="string">            &#125;</span></span><br><span class="line"><span class="string">            // 读原始文档</span></span><br><span class="line"><span class="string">            Document doc  =  new  Document(inPath);</span></span><br><span class="line"><span class="string">            // 转 pdf</span></span><br><span class="line"><span class="string">            doc.save(os,  SaveFormat.PDF);</span></span><br><span class="line"><span class="string">        &#125;  catch  (Exception  e)  &#123;</span></span><br><span class="line"><span class="string">            e.printStackTrace();</span></span><br><span class="line"><span class="string">        &#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">&#125;</span></span><br></pre></td></tr></table></figure>
<h2 id="四、附件下载"><a href="#四、附件下载" class="headerlink" title="四、附件下载"></a>四、附件下载</h2><p>1、aspose 原版 jar 包：<br>链接：<a href="https://pan.baidu.com/s/1Ve-4d5i8PijYxILxSGSq-g，提取码：gpm9" target="_blank" rel="noopener">https://pan.baidu.com/s/1Ve-4d5i8PijYxILxSGSq-g，提取码：gpm9</a></p>
<p>2、aspose track 版 jar 包：<br>链接：<a href="https://pan.baidu.com/s/1AMfyg1noQOPf8PN4C66K1Q，提取码：g9h9" target="_blank" rel="noopener">https://pan.baidu.com/s/1AMfyg1noQOPf8PN4C66K1Q，提取码：g9h9</a></p>
<p>3、JByteMod：<br>链接：<a href="https://pan.baidu.com/s/1mINmfulqD6sUBehPjTnIxA，提取码：3yx8" target="_blank" rel="noopener">https://pan.baidu.com/s/1mINmfulqD6sUBehPjTnIxA，提取码：3yx8</a></p>
<p><img src="http://blogsource.chenkaikai.com/cli_500px.png" alt></p>
<p>参考：<a href="https://blog.csdn.net/shadowkiss/article/details/80868472" target="_blank" rel="noopener">https://blog.csdn.net/shadowkiss/article/details/80868472</a></p>

      
    </div>

    

    
    
    
	
	<div>
	  
		<div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">------ 本文结束 <i class="fa fa-fighter-jet"></i> 感谢阅读 ------</div>
    
</div>
	  
	</div>

    

    
      
    
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/编译/" rel="tag"><i class="fa fa-tag"></i> 编译</a>
          
            <a href="/tags/Word-转-pdf/" rel="tag"><i class="fa fa-tag"></i> Word 转 pdf</a>
          
            <a href="/tags/Aspose/" rel="tag"><i class="fa fa-tag"></i> Aspose</a>
          
            <a href="/tags/crack/" rel="tag"><i class="fa fa-tag"></i> crack</a>
          
            <a href="/tags/JByteMod/" rel="tag"><i class="fa fa-tag"></i> JByteMod</a>
          
            <a href="/tags/javassist/" rel="tag"><i class="fa fa-tag"></i> javassist</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/synchronized-status/" rel="next" title="synchronized 四种锁状态的升级">
                <i class="fa fa-chevron-left"></i> synchronized 四种锁状态的升级
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/protobuf/" rel="prev" title="protobuf 使用指南">
                protobuf 使用指南 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            Overview
          </li>
        </ul>
      

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Jet Chen</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">68</span>
                    <span class="site-state-item-name">posts</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">33</span>
                    <span class="site-state-item-name">categories</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">182</span>
                    <span class="site-state-item-name">tags</span>
                  </a>
                </div>
              
            </nav>
          

          

          
            <div class="links-of-author motion-element">
              
                <span class="links-of-author-item">
                  
                  
                    
                  
                  
                    
                  
                  <a href="https://github.com/goldenJet" title="GitHub &rarr; https://github.com/goldenJet" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
                </span>
              
                <span class="links-of-author-item">
                  
                  
                    
                  
                  
                    
                  
                  <a href="https://twitter.com/goldenJ51015801" title="Twitter &rarr; https://twitter.com/goldenJ51015801" rel="noopener" target="_blank"><i class="fa fa-fw fa-twitter"></i>Twitter</a>
                </span>
              
            </div>
          

          

          
          

          
            
          
          

        </div>
      </div>

      
      <!--noindex-->
        <div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
            
            
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#一、背景"><span class="nav-number">1.</span> <span class="nav-text">一、背景</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#二、Crack"><span class="nav-number">2.</span> <span class="nav-text">二、Crack</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1、初窥-jar-包内详情"><span class="nav-number">2.0.1.</span> <span class="nav-text">1、初窥 jar 包内详情</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2、重写验证的方法"><span class="nav-number">2.0.2.</span> <span class="nav-text">2、重写验证的方法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3、替换字节码文件"><span class="nav-number">2.0.3.</span> <span class="nav-text">3、替换字节码文件</span></a></li></ol></li></ol><li class="nav-item nav-level-2"><a class="nav-link" href="#三、使用"><span class="nav-number">3.</span> <span class="nav-text">三、使用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#四、附件下载"><span class="nav-number">4.</span> <span class="nav-text">四、附件下载</span></a></li></div>
            

          </div>
        </div>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2017 – <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Jet Chen</span>

  

  
</div>









<div class="BbeiAn-info">
    <a target="_blank" href="http://www.miitbeian.gov.cn/" rel="nofollow">浙ICP备17005575号-1</a> <!--a标签中增加nofollow属性，避免爬虫出站。-->| 
	<a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=33010802009043" style="text-decoration:none;padding-left:17px;background:url(/images/icon-police.png) no-repeat left center" rel="nofollow">浙公网安备 33010802009043号</a>	  <!--这里将图标作为了背景，以使得能和后面的文字在同一行-->
</div>

        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
          <span id="scrollpercent"><span>0</span>%</span>
        
      </div>
    

    

    

    
  </div>

  

<script>
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  <script src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>


  


  <script src="/js/src/utils.js?v=7.0.0"></script>

  <script src="/js/src/motion.js?v=7.0.0"></script>



  
  


  <script src="/js/src/affix.js?v=7.0.0"></script>

  <script src="/js/src/schemes/pisces.js?v=7.0.0"></script>




  
  <script src="/js/src/scrollspy.js?v=7.0.0"></script>
<script src="/js/src/post-details.js?v=7.0.0"></script>



  


  <script src="/js/src/bootstrap.js?v=7.0.0"></script>



  


  


  




  

  

  

  

  

  

  

  

  

  

  

  

  

</body>
</html>
